<template>
  <div>
    111111
    <el-table
      :data="tableData"
      border
      style="width: 75%">
      <el-table-column
        align="center"
        prop="id"
        label="编号"
        width="60">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="60">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话"
        width="180">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="入职时间"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            @click="handleEdit(scope.row)">编辑</el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      @current-change="getcurrentPage"
      :current-page="currentPage"
      :page-size="pageSize"
      :total="totals"
      layout="prev, pager, next"
      >
    </el-pagination>
  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData: [],
      pageSize:5,
      currentPage:1,
      totals:0,
    }
  },
  methods: {
    handleEdit(row) {
      console.log(row);
    },
    handleDelete(row) {
      console.log(row);
    },
    getStudent(){
      this.$http.post("/stu/list",{"currentPage":this.currentPage,"pageSize":this.pageSize}).then(res=>{
        //获取fastmoke中模拟的数据data，并赋值给tableData
        this.tableData=res.data.data;
        //获取fastmoke中总数量
        this.totals=res.data.totals;
      }).catch(res=>{
      })
    },
    getcurrentPage(page){
        this.currentPage=page;
        this.getStudent();
    }
  },
  mounted() {
    this.getStudent();
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
